<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>系统发分</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <script src="/scripts/jquery.min.js"></script>
    <script src="/scripts/boot.js" type="text/javascript"></script>
    <script src="/scripts/miniui/miniui.js"></script>

    <style type="text/css">
        html, body {
            font-size: 12px;
            padding: 0;
            margin: 0;
            border: 0;
            height: 100%;
            overflow: hidden;
        }
    </style>
</head>
<body>

<!--<form id="form1" name="form1" method="post" action='/tribeRoute/addTribeMember' enctype="text/plain" >-->
<form id="form1" name="form1">
    <div style="padding-left:11px;padding-bottom:5px; margin-top: 20px">
        <table style="table-layout:fixed; margin: 0 auto;text-align: center;">
            <tr>
                <td style="width:60px;">用户：</td>
                <td >
                    <input id="user" class="mini-buttonedit" onbuttonclick="onButtonEdit" style="width:200px;" name="userOId" textName="nickName" allowInput="false" required="true"/>
                </td>

            </tr>
            <tr>
                <td style="width:60px;">分数：</td>
                <td >
                    <input id="score" name="score" class="mini-textbox" style="width:200px;" type="number" required="true"/>

                </td>

            </tr>

        </table>
    </div>
    <div style="text-align:center;padding:10px; margin-top: 10px">
        <a class="mini-button" onclick="onOk" style="width:60px;margin-right:20px;">确定</a>
        <a class="mini-button" onclick="onCancel" style="width:60px;">取消</a>
    </div>
</form>
<script type="text/javascript">
  mini.parse();
  var form = new mini.Form("form1");
  function SaveData() {
    form.validate();
    if (form.validate() == false){
      alert('表单填写不完整，请确认！')
      return
    }
    var data = {};
    data.userOId = mini.get('user').value;
    data.score = mini.get('score').value;;
    $.ajax({
      url: "/getdata/systemSendScoreAdd",
      type: 'post',
      data: data,
      cache: false,
      success: function (res) {
        if(res){
          alert('加分成功！')
          CloseWindow()
        }
      },
      error: function (error) {
        console.log(error)
      }
    });
  }
  function addTribeMember(data,callBack) {
    $.ajax({
      url: "/tribeRoute/addTribeMember",
      type: 'post',
      data: data,
      cache: false,
      success: function (res) {
        var resultData = JSON.parse(res);
        if(resultData == "请重新登录"){
          parent.window.location="/";
        } else {
          return callBack(resultData);
        };
      },
      error: function (error) {
        console.log(error)
      }
    });
  };
  ////////////////////
  //标准方法接口定义
  function SetData(data) {
  }

  function GetData() {
    var o = form.getData();
    return o;
  }

  function CloseWindow(action) {
    if (action == "close" && form.isChanged()) {
      if (confirm("数据被修改了，是否先保存？")) {
        return false;
      }
    }
    if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
    else window.close();
  }
  function onButtonEdit(e) {
//    console.log(e)
    var btnEdit = mini.get('user');
    mini.open({
      url: "/tribeRoute/tribeMGEditSelectCreater",
      title: "选择用户", width: 600, height: 400,
      ondestroy: function (action) {
        //if (action == "close") return false;
        if (action == "ok") {
          var iframe = this.getIFrameEl();
          var data = iframe.contentWindow.GetData();
          data = mini.clone(data);    //必须
//          console.log(data)
          if (data) {
            btnEdit.setText(data.nickName);
            btnEdit.setValue(data.objectId);
          }
        }
      }
    });

  }

  function onOk(e) {
    SaveData();
  }

  function onCancel(e) {
    CloseWindow("cancel");
  }

</script>
</body>
</html>
